package com.dianning.web.action;

import java.util.Date;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.*;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.interceptor.SessionAware;

import com.dianning.bean.Company;
import com.dianning.bean.Money;
import com.dianning.bean.Profile;
import com.dianning.bean.Resume;
import com.dianning.bean.UserDetail;
import com.dianning.bean.UserInfo;
import com.dianning.bean.Visitor;
import com.dianning.comm.Constant;
import com.dianning.comm.Util;
import com.dianning.exception.DianningException;
import com.dianning.service.UserInfoService;
import com.dianning.service.VisitorService;
import com.dianning.web.interceptor.RemoteAddrAware;
import com.dianning.web.servlet.UserCookie;
import com.dianning.web.servlet.UserSession;

public class Logout extends BaseAction implements SessionAware{

	private static final Log logger = LogFactory.getLog(Logout.class);

	private Map session;
	
	public Map getSession() {
		return session;
	}
	
	public void setSession(Map session) {
		this.session = session;
	}	

	public String execute() {
		try {
			return this.executeMethod(this.getAction());
		} catch (Exception e) {
			logger.error(e);
			return ERROR;
		}
	}

	public String index(){
		this.getSession().remove(Constant.USER_SESSION_KEY);
		HttpServletRequest request = ServletActionContext.getRequest();
        HttpServletResponse response = ServletActionContext.getResponse(); 
		UserCookie uc = new UserCookie(request, response);
		uc.removeCookie(Constant.COOKIE_AUTOLOGIN_AUTH);
        return SUCCESS;
	}
}
